package com.lyc.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

public class MD5 {
	private MD5() {}
	
	public static String encode(String str) {
		try {
			MessageDigest md5 = MessageDigest.getInstance("MD5");
			byte[] digest = md5.digest(str.getBytes("utf-8"));
			return Base64.getEncoder().encodeToString(digest);
		} catch (Exception e) {
			throw new RuntimeException("MD5加密错误",e);
		}
	}
}
